package com.telnetnz.ticketdesk.bean;

import org.springframework.beans.BeanUtils;

import com.telnetnz.ticketdesk.dao.entity.ProjectToUserEntity;
import com.telnetnz.ticketdesk.service.ProjectService;
import com.telnetnz.ticketdesk.service.UserService;

public class ProjectToUser extends ProjectToUserEntity {

	private static final long serialVersionUID = -8245409878613377466L;

	public Project getProject() {
		return ProjectService.getProject(getProjectId());
	}

	public User getUser() {
		return UserService.getUser(getUserId());
	}

	public static ProjectToUser adapt(ProjectToUserEntity entity) {
		if (entity == null)
			return null;
		ProjectToUser bean = new ProjectToUser();
		BeanUtils.copyProperties(entity, bean);
		return bean;
	}

	public ProjectToUserEntity toEntity() {
		return this;
	}
}